package com.gaoyuzhe.controller;

import com.gaoyuzhe.entities.Payment;
import com.gaoyuzhe.to.ReturnValue;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
public class OrderController {
    private static String PAYMENT_URL = "http://cloud-provider-payment/payment";

    @Resource
    private RestTemplate restTemplate;

    @GetMapping("/consumer/insert")
    public ReturnValue<Integer> insert(Payment payment) {
       return  restTemplate.postForObject(PAYMENT_URL+"/insert",payment,ReturnValue.class);
    }

    @GetMapping("/consumer/get/{id}")
    public ReturnValue<Payment> getPayementById(@PathVariable Long id) {
        return  restTemplate.getForObject(PAYMENT_URL+"/get/"+id,ReturnValue.class);

    }
}
